/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nominalitzacions.ui;

import java.awt.BorderLayout;
import java.awt.ComponentOrientation;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author marc.mauri
 */
public class WordEditor extends JFrame {

    JButton acceptButton;
    JTextField wordField;

    public WordEditor() {
        super();
        this.setTitle("Dictionary Editor - Add Word");

        JPanel mainPanel = new JPanel();
        mainPanel.setLayout(new BorderLayout() );

        JPanel centralPanel = new JPanel();
        centralPanel.setLayout(new FlowLayout() );
        centralPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

        JLabel word = new JLabel("Word:");
        centralPanel.add(word);

        wordField = new JTextField();
        wordField.setColumns(11);
        wordField.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent evt) {
               if (wordField.getText().equals("") ) {
                   textEmpty();
               } else {
                   textFull();
               }
           }
        });
        centralPanel.add(wordField);

        mainPanel.add(centralPanel, BorderLayout.CENTER);

        JPanel southPanel = new JPanel();
        southPanel.setLayout(new FlowLayout() );
        southPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

        acceptButton = new JButton("Accept");
        acceptButton.setEnabled(false);
        southPanel.add(acceptButton);

        JButton cancelButton = new JButton("Cancel");
        southPanel.add(cancelButton);

        mainPanel.add(southPanel, BorderLayout.SOUTH);

        this.setContentPane(mainPanel);
        this.setSize(400, 150);
        //this.setResizable(false);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setVisible(true);

    }

    void textEmpty() {
        acceptButton.setEnabled(false);
    }

    void textFull() {
        acceptButton.setEnabled(true);
    }

}

